package io.renren.modules.health.service.impl;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.renren.common.service.impl.CrudServiceImpl;
import io.renren.modules.health.dao.HmWeightRecordDao;
import io.renren.modules.health.dto.HmWeightRecordDTO;
import io.renren.modules.health.entity.HmWeightRecordEntity;
import io.renren.modules.health.service.HmWeightRecordService;
import org.springframework.stereotype.Service;

import java.time.LocalDate;
import java.util.Map;

/**
 * 体重记录
 *
 * @author Mark 
 * @since 1.0.0 2024-04-02
 */
@Service
public class HmWeightRecordServiceImpl extends CrudServiceImpl<HmWeightRecordDao, HmWeightRecordEntity, HmWeightRecordDTO> implements HmWeightRecordService {

    @Override
    public QueryWrapper<HmWeightRecordEntity> getWrapper(Map<String, Object> params){
        String id = (String)params.get("id");
        Long cusId = (Long) params.get("cusId");
        LocalDate updateDate = (LocalDate)params.get("updateDate");

        QueryWrapper<HmWeightRecordEntity> wrapper = new QueryWrapper<>();
        wrapper.eq(StrUtil.isNotBlank(id), "id", id);
        wrapper.eq(cusId != null, "cus_id", cusId);
        wrapper.eq(params.get("updateDate") != null, "update_date", updateDate);

        return wrapper;
    }


}